<?
include "m_head.html";
include("/var/www/html/new/d/class/ProductInfo.php");
$pid=abs($_REQUEST['pid']);
$p=new ProductInfo($pid,$soap);
$p_info=$p->pInfo();
//var_dump($p_info);
$time=strtotime("+".$p_info['ddays']." days");
$begintime=date("Y-m-d",$time);
/*产品有效起始日期*/
$begintime=$p->getMinValidTime($pid,$begintime);
if($begintime==-1){
	echo '<script>window.location="sysMsg.html?act=write&msg=无有效出行日期，请更换产品"</script>';
	exit;
}
/*产品有效起始日期end*****/
$tprice=$p->uPrice($did,$begintime);
$buytum=$p_info['buy_limit_low']?$p_info['buy_limit_low']:1;
?>
<title>订单填写</title>
<style>
	#dp-popup{font-size:1em;width:100%; height:800px; position:absolute; top:0px; z_index:999;background:#fff;  }
	#dp-popup .dp-title{text-align:center;}
	#dp-popup .dp-cal{margin:2%;}
	#dp-popup h2{text-align:center; background:#008FC2; color:#fff; font-size:1em; padding:0.3em 0; border:2px solid #9EC3E3; width:100%;}
	.dp-nav-prev{float:left; margin-left:1em;}
	.dp-nav-prev a{background:#fff; padding:0px 5px; margin-top:5px; font-weight:bold;float:left;}
	.dp-nav-next{float:right;margin-right:1em;}
	.dp-nav-next a{background:#fff; padding:0px 5px; margin-top:5px; font-weight:bold;float:right;}
	.dp-calendar{ width: 100%; border:2px solid #9EC3E3;border-top:none;}
	table.jCalendar { border-collapse: collapse; font-family: Arial; width: 100%;}
	table.jCalendar th{padding:0.2em 0;font-weight:normal; font-size:0.8em;}
	table.jCalendar td{cursor:pointer; border: 1px solid #ccc; color: #008FC2; font-weight:bold;   text-align: center; height:3em; }
	table.jCalendar td.selected{background:#008FC2; color:#fff}
	table.jCalendar td.disabled{color:#ccc;cursor:default;}
	#begintime{width:100%; margin-right:1em; border:1px solid #ccc; height:1.8em; line-height:1.8em; text-align:center}
</style>
<script src="js/date.js"></script>
<script>
$(document).ready(function(){
		var ddays=$("#begintime").attr("ddays")
		$("#begintime").datePicker({
			clickInput:true,
			mobile:true,
			htmlText:true
		});
});
</script>
    <!--头部-->
    <header class="head">
		<a href="tlist.html?lid=<?=$lid?>&did=<?=$did?>" class="heada back"></a>
        <h1>填写订单</h1>
    </header>
    <!--头部END-->
    <!--确认信息-->
    <article class="hydl">
		<input type="hidden" id="tprice" value="<?=$tprice/100?>"/>
		<input type="hidden" id="minbuytnum" value="<?=$p_info['buy_limit_low']?>"/>
		<input type="hidden" id="maxbuytnum" value="<?=$p_info['buy_limit_up']?>"/>
		<input type="hidden" id="minbegintime" value="<?=$begintime?>"/>
		<!-- <form action="orderPay.html" method="post" name="order"> -->
			<input type="hidden" name="pid" id="pid" value="<?=$pid?>"/>
			<input type="hidden" name="did" id="did" value="<?=$did?>"/>
			<h5>
				产品：<?=$p_info['ltitle'].$p_info['ttitle']?><br />
				价格：<span class="yel">¥<?=$tprice/100?></span>
			</h5>
			<ul>
				<li class="bord">
					<span>预&nbsp;订&nbsp;数&nbsp;量：</span>
					<i class="qrxiae"><a href="#" class="reduce sub"></a><input type="text" class="nomb" name="tnum" value="1" id="tnum" /><a href="#" class="pulsgm add"></a></i>
				</li>
					<li class="bord">
					<span>联系人姓名&nbsp;：</span>
					<input type="text" name="ordername" id="ordername" class="qrxxintxt" />
				</li>  
				

				<li class="bord">
					<span>联系人手机&nbsp;：</span>
					<input type="text" name="ordertel" id="ordertel" class="qrxxintxt" />
				</li>
				<li class="bord">
					<span>游&nbsp;玩&nbsp;日&nbsp;期：</span>
					<i class="qrxi"><span id="begintime"><?=$begintime?></span></i>
				</li>
				<li class="bord">
					<span>总&nbsp;&nbsp;金&nbsp;&nbsp;额&nbsp;：</span>
					<i class="qrxiae"><b class="yel" id="totalMOney"><?=$tprice*1/100?></b>元</i>
				</li>
				<?if($tprice>0){?>
				<li style="color:red">(支付后订单暂不支持退款，请谨慎购买)</li>
				<?}?>
				<li><input type="button" value="确认<?=$tprice==0?"":"并支付"?>" class="my_but wid100 no_margin" /></li>
				初始账号：取票人手机号<br>
				初始密码：手机的后六位数
			</ul>
		<!-- </form> -->
    </article>
    <!--确认信息END-->
<script>
	var changemoney=function (tprice,tnum){
		tprice*=100;
		tprice=parseInt(tprice);
		var totalMOney;
		var tnum=parseInt(tnum)
		if(tnum>parseInt($("#maxbuytnum"))){
			tunm=parseInt($("#maxbuytnum"));
		}
		if(tnum<parseInt($("#minbuytnum"))){
			tunm=parseInt($("#minbuytnum"));
		}
		if(tnum<=0){
			tnum=1;
		}
		$("#tnum").val(tnum);
		totalMOney=tprice*tnum;
		$("#totalMOney").html(totalMOney/100);
	}
	$(".add").click(function(){
		var tnum=parseInt($("#tnum").val())+1;
		$("#tnum").val(tnum);
		$("#tnum").blur();
		return false;
	})
	$(".sub").click(function(){
		var tnum=parseInt($("#tnum").val())-1;
		$("#tnum").val(tnum);
		$("#tnum").blur()
		return false;
	})
	$("#tnum").blur(function(){
		changemoney($("#tprice").val(),$(this).val());
	
	})
	$("#tnum").keyup(function(){
		var pattern=/[^0-9]/g;
		var tnum=$(this).val();
		tnum=tnum.replace(pattern,"");
		$(this).val(tnum);
		return false;
	})
	$(".my_but").click(function(){
		if(!$("#ordername").val()){
			alert("请输入取票人姓名");
			return false;
		}
		if(!$("#ordertel").val()){
			alert("请输入手机号");
			return false;
		}
		var pattern=/^[0-9]{11}$/;
		if(!pattern.test($("#ordertel").val())){
			alert("手机格式错误");
			return false;
		}
		var dpattern=/^\d{4}-\d{2}-\d{2}$/;
		if(!dpattern.test($("#begintime").html())){
			alert("日期错误，请填写2013-07-06格式");
			return false;
		}
		if($("#begintime").html()<$("#minbegintime").val()){
			alert("游玩日期不能小于"+$("#minbegintime").val());
			return false;
		}
	//	document.forms["order"].submit();
		window.location="orderPay.html?pid="+$("#pid").val()+"&did="+$("#did").val()+"&tnum="+$("#tnum").val()+"&ordername="+$("#ordername").val()+"&ordertel="+$("#ordertel").val()+"&begintime="+$("#begintime").html();
		
		this.disabled=true;
	})
</script>
<?//include "m_foot.html"?>